package competition;

import java.util.Scanner;

/**
 * Author: 笨蛋超人不会飞
 * Date:  10:04
 */
public class c_03 {
    public static void main(String[] args) {
        int n;
        Scanner scanner=new Scanner(System.in);

//        通过Scanner输入n
        n=scanner.nextInt();
        for (int i = 0; i < n; i++) {
            int x;
            int h;
            x=scanner.nextInt();
            h=scanner.nextInt();
            if(x>=h){
                System.out.println(x+h);
            }else {
                System.out.println(2*h);
            }

        }

    }
}
